package com.qingcheng.util;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;

/**
 * 创建高级客户端对象工厂类
 */
public class RestClientFactory {
    /**
     * 获取高级客户端对象
     * @param hostName ip地址
     * @param port 端口号
     * @return 高级客户端对象
     */
    public static RestHighLevelClient getRestHighLevelClient(String hostName,Integer port){
        HttpHost httpHost = new HttpHost(hostName,port,"http");
        RestClientBuilder builder = RestClient.builder(httpHost);
        return new RestHighLevelClient(builder);//高级客户端对象
    }
}
